<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% content_for :page_title, @user_data[:short_name] %>

<div class="ic-Profile-layout">
  <div class="ic-Profile-layout__Primary">
    <%= render 'shared/profile' %>
  </div>

  <div class="ic-Profile-layout__Secondary">
    <% if @user_data[:can_edit] && !can_do(@domain_root_account, @current_user, :manage) %>
      <button data-event="editProfile" class="hide-if-editing Button">{{> icons/edit}} {{#t}}Edit Profile{{/t}}</button>
      <button data-event="cancelEditProfile" class="show-if-editing Button">{{> icons/edit}} {{#t}}Cancel Editing{{/t}}</button>
    <% elsif @user_data[:can_edit] && can_do(@domain_root_account, @current_user, :manage) %>
        <div class="al-dropdown__container">
          <a class="al-trigger btn" role="button" href="#" id="profileDropdown">
            {{> icons/more}}
            <span class="screenreader-only">More</span>
          </a>
          <ul aria-labeledby="profileDropdown" class="al-options" role="menu" tabindex="0" aria-hidden="true" aria-expanded="false" >
            <li class="hide-if-editing"><a data-event="editProfile" role="menuitem">{{#t}}Edit Profile{{/t}}</a></li>
            <li class="show-if-editing"><a data-event="cancelEditProfile" role="menuitem">{{#t}}Cancel Editing{{/t}}</a></li>
            <li><a href="<%= user_path(@user.id) %>"role="menuitem">{{#t}}Account Details{{/t}}</a></li>
            <% if @user != @current_user %>
              <li><a href="<%= user_profile_url(@user, :become_user_id => @user) %>"role="menuitem"> {{#t}}Act as User{{/t}}</a></li>
            <% end %>
          </ul>
        </div>
    <% end %>
  </div>

</div>
